package com.cskaoyan.controller.advertising;

import com.cskaoyan.bean.bo.AdminCouponCreateBo;
import com.cskaoyan.bean.bo.AdminCouponDeleteBo;
import com.cskaoyan.bean.bo.AdminCouponUpdateBo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.vo.*;
import com.cskaoyan.service.AdvertisingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("admin/coupon")
public class AdvertisingCouponController {
    @Autowired
    AdvertisingService advertisingService;
    /**
     * @Description: 优惠劵管理
     * @Description: /admin/coupon/list
     * @date: 2022/9/7 14:42
     * @author: zyc
     * @since JDK 1.8
     */
    @GetMapping("list")
    public BaseRespVo getCouponList(Integer page, Integer limit, String name, Short type, Short status, String sort,String order){
        AdminCouponListVo listVo = advertisingService.getCouponList(page,limit,name,type,status,sort,order);
        return BaseRespVo.ok(listVo);
    }

    /**
     * @Description: 新增优惠券
     * @Description: /admin/coupon/create
     * @date: 2022/9/7 19:16
     * @author: zyc
     * @since JDK 1.8
     */
    @PostMapping("create")
    public BaseRespVo createCoupon(@RequestBody AdminCouponCreateBo createBo){
        AdminCouponCreateVo createVo = advertisingService.createCoupon(createBo);
        return BaseRespVo.ok(createVo);
    }

    /**
     * @Description: 更新优惠券信息
     * @Description: /admin/coupon/update
     * @date: 2022/9/7 20:35
     * @author: zyc
     * @since JDK 1.8
     */
    @PostMapping("update")
    public BaseRespVo updateCoupon(@RequestBody AdminCouponUpdateBo updateBo){
        AdminCouponUpdateVo updateVo = advertisingService.updateCoupon(updateBo);
        return BaseRespVo.ok(updateVo);
    }

    /**
     * @Description: 删除优惠券信息
     * @Description: /admin/coupon/delete
     * @date: 2022/9/7 22:20
     * @author: zyc
     * @since JDK 1.8
     */
    @PostMapping("delete")
    public BaseRespVo deleteCoupon(@RequestBody AdminCouponDeleteBo deleteBo){
        advertisingService.deleteCoupon(deleteBo);
        return BaseRespVo.ok();
    }

    /**
     * @Description: 详细信息回显
     * @Description: /admin/coupon/read
     * @date: 2022/9/7 22:39
     * @author: zyc
     * @since JDK 1.8
     */
    @GetMapping("read")
    public BaseRespVo readCoupon(Integer id){
        AdminCouponReadVo readVo = advertisingService.getCouponById(id);
        return BaseRespVo.ok(readVo);
    }

    /**
     * @Description: 详细表查询
     * @Description: /admin/coupon/listuser
     * @date: 2022/9/7 22:54
     * @author: zyc
     * @since JDK 1.8
     */
    @GetMapping("listuser")
    public BaseRespVo getListUser(Integer page,Integer limit,Integer couponId,Integer userId,Short status,String sort,String order){
        AdminCouponListUserVo listUserVo = advertisingService.getListUser(page,limit,couponId,userId,status,sort,order);
        return BaseRespVo.ok(listUserVo);
    }
}
